# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
pkgname=schemacrawler
pkgver=16.19.11
pkgrel=1
pkgdesc="Free database schema discovery and comprehension tool"
arch=('any')
url="https://www.schemacrawler.com"
license=('GPL3')
depends=('java-runtime' 'graphviz')
makedepends=('maven' 'java-environment=17' 'unzip')
source=("$pkgname-$pkgver.tar.gz::https://github.com/schemacrawler/SchemaCrawler/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('caa6cfea0d4846bbdf22d82c94b8a38c09920acf6cddcddefbf663f1c974dde04ea78c1ce54374da8f982d5976f6b7665ac86a0f94cbcac5567bad733efe8159')

build() {
  cd SchemaCrawler-$pkgver

  export JAVA_HOME="/usr/lib/jvm/java-17-openjdk"
  mvn -Ddistrib -DskipTests package
}

package() {
  cd SchemaCrawler-$pkgver/schemacrawler-distrib/target
  unzip schemacrawler-$pkgver-distribution.zip
  mkdir -p "$pkgdir"/{opt,usr/bin}
  cp -r schemacrawler-$pkgver-distribution "$pkgdir"/opt/schemacrawler
  echo -e '#!/bin/bash\ncd /opt/schemacrawler/_schemacrawler/bin\n./schemacrawler.sh $@' > "$pkgdir"/usr/bin/schemacrawler
  chmod -R +r "$pkgdir"/opt/schemacrawler
  chmod +x "$pkgdir"/usr/bin/schemacrawler
}

# vim: ts=2 sw=2 et:
